<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>INSPINIA | Dashboard</title>
        <link href="/tpshop/Public/admin/css/bootstrap.min.css" rel="stylesheet">
    <link href="/tpshop/Public/admin/font-awesome/css/font-awesome.css" rel="stylesheet">
    <link href="/tpshop/Public/admin/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <link href="/tpshop/Public/admin/css/plugins/toastr/toastr.min.css" rel="stylesheet">
    <link href="/tpshop/Public/admin/js/plugins/gritter/jquery.gritter.css" rel="stylesheet">
    <link href="/tpshop/Public/admin/css/animate.css" rel="stylesheet">
    <link href="/tpshop/Public/admin/css/style.css" rel="stylesheet">
    <link href="/tpshop/Public/admin/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="/tpshop/Public/admin/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
    <!-- FooTable -->
    <link href="/tpshop/Public/admin/css/plugins/footable/footable.core.css" rel="stylesheet">
    <style type="text/css">
        .level1 td{
            background: #eee;
        }
        .level2 td{
            background: #f8f8f8;
            cursor: pointer;
        }
        .level3{
            display: none;
        }
    </style>
        <!-- Mainly scripts -->
    <script src="/tpshop/Public/admin/js/jquery-2.1.1.js"></script>
    <script src="/tpshop/Public/admin/js/bootstrap.min.js"></script>
    <script src="/tpshop/Public/admin/js/plugins/metisMenu/jquery.metisMenu.js"></script>
    <script src="/tpshop/Public/admin/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>


    <!-- Custom and plugin javascript -->
    <script src="/tpshop/Public/admin/js/inspinia.js"></script>
    <script src="/tpshop/Public/admin/js/plugins/pace/pace.min.js"></script>

    <!-- jQuery UI -->
    <script src="/tpshop/Public/admin/js/plugins/jquery-ui/jquery-ui.min.js"></script>
    <!-- FooTable -->
    <script src="/tpshop/Public/admin/js/plugins/footable/footable.all.min.js"></script>
    <!-- SUMMERNOTE -->
    <script src="/tpshop/Public/admin/js/plugins/summernote/summernote.min.js"></script>

    <!-- Page-Level Scripts -->
    <script>
        $(document).ready(function() {

            $('.footable').footable();

            $('.summernote').summernote();

            $('.delete').click(function(){
                if (!confirm("是否删除!")) {
                        return false;
                }
            })

        });
        $("#upload").click(function(){
            $.upload({
                url: "/tpshop/Public/uploads", 
                fileName: 'file', 
                dataType: 'text',
                onSend: function() {
                    return true;
                },
                onComplate: function(data) {
                    $("#img").val(data);
                    $("#preview").html('<img style="height:80px;" src="U('+data+')">');
                }
            });
        })
    </script>
</head>
<body>
    <div id="wrapper">
                <nav class="navbar-default navbar-static-side" role="navigation">
            <div class="sidebar-collapse">
                <ul class="nav metismenu" id="side-menu">
                    <li class="nav-header">
                        <div class="dropdown profile-element">
                            <span>
                                <img style="width:50px;" alt="image" class="img-circle" src="/tpshop/Public/img/1.png" />
                            </span>
                            <a data-toggle="dropdown" class="dropdown-toggle" href="#">
                                <span class="clear">
                                    <span class="block m-t-xs">
                                        <strong class="font-bold"><?php echo ($_SESSION['admin_name']); ?></strong>
                                    </span>
                                </span>
                            </a>
                        </div>
                        <div class="logo-element">
                            <img style="width:50px;" alt="image" class="img-circle" src="/tpshop/Public/img/1.png" />
                        </div>
                    </li>
                    <li <?php if(CONTROLLER_NAME == 'Index'): ?>class="active"<?php endif; ?>>
                        <a href="<?php echo U('Admin/Index/index');?>"><i class="fa fa-home"></i> <span class="nav-label">主页</span></a>
                    </li>
                    <li <?php if(CONTROLLER_NAME == 'Order'): ?>class="active"<?php endif; ?>>
                        <a href="<?php echo U('Admin/Order/index');?>"><i class="fa fa-shopping-cart"></i> <span class="nav-label">订单管理</span></a>
                    </li>
                    <li <?php if(CONTROLLER_NAME == 'Catalog'): ?>class="active"<?php endif; ?>>
                        <a href="<?php echo U('Admin/Catalog/index');?>"><i class="fa fa-th-large"></i> <span class="nav-label">分类管理</span></a>
                    </li>
                    <li <?php if(CONTROLLER_NAME == 'Product'): ?>class="active"<?php endif; ?>>
                        <a href="<?php echo U('Admin/Product/index');?>"><i class="fa fa-gift"></i> <span class="nav-label">商品管理</span></a>
                    </li>
                    <li <?php if(CONTROLLER_NAME == 'User'): ?>class="active"<?php endif; ?>>
                        <a href="<?php echo U('Admin/User/index');?>"><i class="fa fa-users"></i> <span class="nav-label">会员管理</span></a>
                    </li>
                    <li <?php if(CONTROLLER_NAME == 'Website'): ?>class="active"<?php endif; ?>>
                        <a href="<?php echo U('Admin/Website/index');?>"><i class="fa fa-wrench"></i> <span class="nav-label">网站设置</span></a>
                    </li>
                </ul>
            </div>
        </nav>
        <div id="page-wrapper" class="gray-bg dashbard-1">
                        <div class="row border-bottom">
                <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
                    <div class="navbar-header">
                        <a class="navbar-minimalize minimalize-styl-2 btn btn-primary " href="#"><i class="fa fa-bars"></i> </a>
                    </div>
                    <ul class="nav navbar-top-links navbar-right">
                        <li>
                            <span class="m-r-sm text-muted welcome-message">欢迎来到后台管理.</span>
                        </li>
                        <li>
                            <a href="<?php echo U("Admin/auth/logout");?>">
                                <i class="fa fa-sign-out"></i>退出
                            </a>
                        </li>
                    </ul>
                </nav>
            </div>
            <div class="row">
                <div class="col-lg-12">
                                <div class="row wrapper border-bottom white-bg page-heading">
                <div class="col-md-10">
                    <h2>分类管理</h2>
                    <ol class="breadcrumb">
                        <li>
                            <a href="<?php echo U('Admin/Index/index');?>">主页</a>
                        </li>
                        <li class="active">
                            <strong>分类管理</strong>
                        </li>
                    </ol>
                </div>
                <div class="col-md-2">
                    <h2><a class="btn btn-primary btn-rounded pull-right" href="<?php echo U('Admin/Catalog/add');?>">添加分类</a></h2>
                </div>
            </div>
            <div class="wrapper wrapper-content">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>所有分类</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">

                        <table class="table">
                            <thead>
                            <tr>

                                <th width="120">编号</th>
                                <th>分类名称</th>
                                <th width="120">操作</th>

                            </tr>
                            </thead>
                            <tbody>
                            <?php if(is_array($level1)): $i = 0; $__LIST__ = $level1;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$l1): $mod = ($i % 2 );++$i;?><tr class="level1">
                                <td><?php echo ($l1["id"]); ?></td>
                                <td><?php echo ($l1["name"]); ?></td>
                                <td class="text-right">
                                    <div class="btn-group">
                                        <a href="<?php echo U('Admin/Catalog/edit/id/'.$l1['id']);?>" class="btn-white btn btn-xs">编辑</a>
                                        <a href="<?php echo U('Admin/Catalog/delete/id/'.$l1['id']);?>" class="btn-white btn btn-xs delete">删除</a>
                                    </div>
                                </td>
                            </tr>
                                <?php $level2=M('product_catalog')->where("parent_id = ".$l1['id'])->select()?>
                                <?php if(is_array($level2)): $i = 0; $__LIST__ = $level2;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$l2): $mod = ($i % 2 );++$i;?><tr class="level2" id="level<?php echo ($l2["id"]); ?>">
                                    <td><?php echo ($l2["id"]); ?></td>
                                    <td>╰——<?php echo ($l2["name"]); ?></td>
                                    <td class="text-right">
                                        <div class="btn-group">
                                            <a href="<?php echo U('Admin/Catalog/edit/id/'.$l2['id']);?>" class="btn-white btn btn-xs">编辑</a>
                                            <a href="<?php echo U('Admin/Catalog/delete/id/'.$l2['id']);?>" class="btn-white btn btn-xs delete">删除</a>
                                        </div>
                                    </td>
                                </tr>
                                    <?php $level3=M('product_catalog')->where("parent_id = ".$l2['id'])->select()?>
                                    <?php if(is_array($level3)): $i = 0; $__LIST__ = $level3;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$l3): $mod = ($i % 2 );++$i;?><tr class="level3 parent_level<?php echo ($l2["id"]); ?>">
                                        <td><?php echo ($l3["id"]); ?></td>
                                        <td>╰——╰——<?php echo ($l3["name"]); ?></td>
                                        <td class="text-right">
                                            <div class="btn-group">
                                                <a href="<?php echo U('Admin/Catalog/edit/id/'.$l3['id']);?>" class="btn-white btn btn-xs">编辑</a>
                                                <a href="<?php echo U('Admin/Catalog/delete/id/'.$l3['id']);?>" class="btn-white btn btn-xs delete">删除</a>
                                            </div>
                                        </td>
                                    </tr><?php endforeach; endif; else: echo "" ;endif; endforeach; endif; else: echo "" ;endif; endforeach; endif; else: echo "" ;endif; ?>
                            </tbody>
                        </table>

                    </div>
                </div>
            </div>
    <script type="text/javascript">
        $(function(){
            $('.level2 td').click(function(){
                var id = $(this).parents('tr').attr('id');
                var cls = '.parent_'+id;
                $(cls).toggle('slow');
            });
        })
    </script>
                                        <div class="footer">
                        <div>
                            <strong>Copyright</strong> Example Company &copy; 2016-2016
                        </div>
                    </div>
                </div>
            </div>
        </div>
     </div>
</body>
</html>